package com.site.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * Created by shengquan.wu on 2018/6/6.
 */
public class JdkProxyTest {

    public static void main(String[] args) {
        Car car = new Car();
        InvocationHandler hander = new TimeHandler(car);
        Class<?> clazz = car.getClass();

        /**
         * loader 类加载器
         * interfaces 实现接口
         * hander InvocationHandler
         */
        Moveable m=(Moveable) Proxy.newProxyInstance(clazz.getClassLoader(), clazz.getInterfaces(), hander);
        m.move();
    }
}
